package com.zhoukx.memento.theory;

/**
 * @ClassName Client
 * @Description:
 * @Author zhoukx
 * @Date 2020/8/18
 **/
public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();
        // 保存当前的状态
        originator.setState("状态1 攻击力100");
        caretaker.add(originator.saveStateMemento());


        originator.setState("状态2  攻击力 50");
        caretaker.add(originator.saveStateMemento());

        originator.setState("状态3  攻击力 50");
        caretaker.add(originator.saveStateMemento());


        System.out.println("当前状态是="+originator.getState());
        // 希望恢复到状态1
        originator.getStateFromMemento(caretaker.get(0));
        System.out.println("恢复到状态1  ，当前的状态是");
        System.out.println("当前状态是="+originator.getState());

    }
}
